#include "DatReader.h"
#include "FileSort.h"
int main() {

    /* 读取单个dat */
    string filename = "input/result 000100800.00000s.dat";
    int ncell = 1719*2104;
    
    DatReader reader;
    vector<ResultData> resultData = reader.load(filename, ncell);
    for (size_t i = 0; i < 10; i++) {
        cout << resultData[i].x << " " << resultData[i].y 
        << " " << resultData[i].z << " " << resultData[i].zb 
        << " " << resultData[i].u << " " << resultData[i].v 
        << " " << resultData[i].flag << " " << resultData[i].Total_In << endl;
    }
    

    /* 读取某文件夹下所有dat */
    string datFolder = "input";

    FileSort fileSort; // 创建 FileSort 对象，读取input文件夹下所有dat文件，并按时间排序从小到大
    vector<string> sortedFilenames = fileSort.processFiles("input");
    
    for (size_t i = 0; i < sortedFilenames.size(); i++) {
        cout << sortedFilenames[i] << endl; 
        string filename = datFolder + "/" + sortedFilenames[i]; // 将文件名和路径拼接起来
        vector<ResultData> resultData1 = DatReader().load(filename, ncell);
        
        // 后续处理resultData的代码

        /* --code-- */

        resultData1.clear();
    }
    
    return 0;
}